package controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.Book_Deal;

@WebServlet("/OrderUnsubscribe")
public class OrderUnsubscribe extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private Book_Deal deal = new Book_Deal();
    public OrderUnsubscribe() {
        super();
    }

	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		res.setCharacterEncoding("utf-8");
		
		String order_id = req.getParameter("order_id");
		String number = req.getParameter("number");
		String book_id = req.getParameter("book_id");
		String book_img_src = req.getParameter("book_img_src");
		String book_price = req.getParameter("book_price");
		String order_price = req.getParameter("order_price");
		String order_time = req.getParameter("order_time");
		
		boolean falg = deal.book_deal(order_id,number,book_id,book_img_src,book_price,order_price,order_time);
		if(falg) {
			res.sendRedirect("/TeachingTest/main?page=order-list&target=1");
		}else {
			res.sendRedirect("/TeachingTest/main?page=order-list&target=1");
		}
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		doGet(req, res);
	}

}
